﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sausage.Web.DataModel;

namespace Sausage.Web.Domain
{
    public class RoleHelper
    {
        public static List<Role> GetRoleListByUser(User targetUser)
        {
            using (var context = new SausageEntities())
            {
                return (from role in context.Role
                 join userRole in context.UserRole on role.RoleID equals userRole.RoleID
                 join user in context.User on userRole.UserID equals user.UserID
                 where user.UserID == targetUser.UserID
                 select role).ToList();
            }
        }
    }
}
